package com.xbell.app.sys.common;

public class PageInfo {
	private int page =1;
	private int rows = 40;
	private String defaultOrder = "";//默认排序字段
	private String ord;
	private String sort;
	private boolean isAll = false;

	public PageInfo() {
	}

	public PageInfo(int page, int rows, String ord, String sort, String defaultOrder, boolean isAll) {
		this.page = page;
		this.rows = rows;
		this.ord = ord;
		this.sort = sort;
		this.defaultOrder = defaultOrder;
		this.isAll = isAll;
	}

	public boolean isAll() {
		return isAll;
	}

	public PageInfo setAll(boolean all) {
		isAll = all;
		return this;
	}

	public int getPage() {
		return page;
	}

	public int getRows() {
		return rows;
	}

	public String getOrd() {
		return ord;
	}

	public String getSort() {
		return sort;
	}

	public void setPage(int page) {
		this.page = page;
	}

	public void setRows(int rows) {
		this.rows = rows;
	}

	public void setOrd(String ord) {
		this.ord = ord;
	}

	public void setSort(String sort) {
		this.sort = sort;
	}

	public String getDefaultOrder() {
		return defaultOrder;
	}

	public PageInfo setDefaultOrder(String defaultOrder) {
		this.defaultOrder = defaultOrder;
		return this;
	}

	/**
	 * 增加默认排序
	 * pageInfo.setDefaultorder("optime desc,xh desc");
	 * @return {@link PageInfo }
	 * @author GXY
	 * @date 2023/07/19
	 */
	public String orderSql() {
		if (sort != null && sort.trim().length() > 0) {
			defaultOrder = sort.trim() + " " + ("asc".equals(ord) ? "asc" : "desc");
		}
		return defaultOrder.length() > 0 ? (" order by " + defaultOrder) : "";
	}

}
